package com.example.servletdemo.filter.chain;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

//@WebFilter(filterName = "Filter1",urlPatterns = "/*")
public class Filter1 implements Filter {

    private String filterName;

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        filterName = filterConfig.getFilterName();
        System.out.println(filterName +":init");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println(filterName +":doFilter------------------------------------------");
        filterChain.doFilter(servletRequest,servletResponse);
        System.out.println(filterName +":执行完成------------------------------------------");
    }

    @Override
    public void destroy() {
        System.out.println(filterName +":destroy");
    }
}
